import { PageDto, PageData, PutDto, PutRes, DisableDto, DisableRes } from "~/rest";
import { Gateway, getGateway } from "@/droplet-bus/core.define";

import { app_gateway } from "./core.local";
import { AppDueTpl } from "./schema.due";
import { MarketOrder } from "./schema.order";

export const AppDueTplGateway: Gateway = getGateway(app_gateway, "river_market_app_due_tpl");
export type getAppDueTplDto = PageDto<AppDueTpl>;
export type putAppDueTplDto = PutDto<AppDueTpl>;
export type deleteAppDueTplDto = DisableDto;

export interface AppDueTplInterfaceWithDerive<T> {
  /** APP服务期 */
  getAppDueTpl(dto: T & getAppDueTplDto): Promise<PageData<AppDueTpl>>;
  /** 超级管理员创建/修改商品模板 */
  putAppDueTpl(dto: T & putAppDueTplDto): Promise<PutRes<AppDueTpl>>;
  /** 超级管理员删除商品模板 */
  deleteAppDueTpl(dto: T & deleteAppDueTplDto): Promise<DisableRes>;
}

export const AppDueSkuGateway: Gateway = getGateway(app_gateway, "river_market_app_due_sku");
export type postAppDueSkuDto = { tplId: AppDueTpl["id"] };

export interface AppDueSkuInterfaceWithDerive<T> {
  /** 用户根据商品模板创建订单（运营中心回收钻石）*/
  postAppDueSku(dto: T & postAppDueSkuDto): Promise<PutRes<MarketOrder>>;
}
